package com.tyk.bookstore.back.auth.valid.provider;

import com.tyk.bookstore.back.auth.model.query.SendMsgCodeQuery;
import com.tyk.bookstore.back.auth.valid.group.EmailValidGroup;
import com.tyk.bookstore.back.auth.valid.group.MobilePhoneValidGroup;
import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider;

import java.util.ArrayList;
import java.util.List;

public class SendCaptchaQueryGroupValidProvider implements DefaultGroupSequenceProvider<SendMsgCodeQuery> {

	@Override
	public List<Class<?>> getValidationGroups(SendMsgCodeQuery query) {
		ArrayList<Class<?>> groupSequenceList = new ArrayList<>();
		groupSequenceList.add(SendMsgCodeQuery.class);

		if (query != null) {
			if (query.getType() != null) {
				switch (query.getType()) {
					case PHONE -> groupSequenceList.add(MobilePhoneValidGroup.class);
					case EMAIL -> groupSequenceList.add(EmailValidGroup.class);
				}
			}
		}

		return groupSequenceList;
	}

}
